package com.add;

import com.lineage.config.Configtf;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_HPUpdate;
import com.lineage.server.serverpackets.S_MPUpdate;
import com.lineage.server.serverpackets.S_NPCTalkReturn;
import com.lineage.server.serverpackets.S_OwnCharStatus2;
import com.lineage.server.serverpackets.S_SPMR;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.logging.Logger;

public class TFUpdate {
  private static Logger _log = Logger.getLogger(TFUpdate.class.getName());
  
  private static TFUpdate _instance;
  
  public static TFUpdate getInstance() {
    if (_instance == null)
      _instance = new TFUpdate(); 
    return _instance;
  }
  
  public boolean PcCommand(L1PcInstance pc, String cmd) {
    if (cmd.equalsIgnoreCase("aaa")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Str() >= Configtf.tfup1) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Str(pc.get_other2().get_Str() + Configtf.tftype1);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addStr(Configtf.tftype1);
          pc.sendPackets((ServerBasePacket)new S_OwnCharStatus2(pc));
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("bbb")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Dex() >= Configtf.tfup2) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Dex(pc.get_other2().get_Dex() + Configtf.tftype2);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addDex(Configtf.tftype2);
          pc.sendPackets((ServerBasePacket)new S_OwnCharStatus2(pc));
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("ccc")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Int() >= Configtf.tfup3) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Int(pc.get_other2().get_Int() + Configtf.tftype3);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addInt(Configtf.tftype3);
          pc.sendPackets((ServerBasePacket)new S_OwnCharStatus2(pc));
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("ddd")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Attack() >= Configtf.tfup4) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Attack(pc.get_other2().get_Attack() + Configtf.tftype4);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addDmgup(Configtf.tftype4);
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("eee")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_BowAttack() >= Configtf.tfup5) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_BowAttack(pc.get_other2().get_BowAttack() + Configtf.tftype5);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addBowDmgup(Configtf.tftype5);
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("fff")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Hp() >= Configtf.tfup6) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Hp(pc.get_other2().get_Hp() + Configtf.tftype6);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addMaxHp(Configtf.tftype6);
          pc.sendPackets((ServerBasePacket)new S_HPUpdate(pc.getCurrentHp(), pc.getMaxHp()));
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("ggg")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Mp() >= Configtf.tfup7) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Mp(pc.get_other2().get_Mp() + Configtf.tftype7);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addMaxMp(Configtf.tftype7);
          pc.sendPackets((ServerBasePacket)new S_MPUpdate(pc.getCurrentMp(), pc.getMaxMp()));
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("hhh")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_ReductionDmg() >= Configtf.tfup8) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_ReductionDmg(pc.get_other2().get_ReductionDmg() + Configtf.tftype8);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addother_ReductionDmg(Configtf.tftype8);
        }  
      TF(pc);
    } else if (cmd.equalsIgnoreCase("iii")) {
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Sp() >= Configtf.tfup9) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Sp(pc.get_other2().get_Sp() + Configtf.tftype9);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addSp(Configtf.tftype9);
          pc.sendPackets((ServerBasePacket)new S_SPMR(pc));
        }  
      TF(pc);
    } else {
      if (!cmd.equalsIgnoreCase("jjj"))
        return false; 
      boolean isTalent = false;
      if (pc.get_other2().get_TfCount() > 0)
        isTalent = true; 
      if (isTalent)
        if (pc.get_other2().get_Mr() >= Configtf.tfup10) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("该天赋技能已满"));
          isTalent = false;
        } else {
          pc.get_other2().set_Mr(pc.get_other2().get_Mr() + Configtf.tftype10);
          pc.get_other2().set_TfCount(pc.get_other2().get_TfCount() - 1);
          pc.get_other2().set_TfCount1(pc.get_other2().get_TfCount1() + 1);
          pc.addMr(Configtf.tftype10);
          pc.sendPackets((ServerBasePacket)new S_SPMR(pc));
        }  
      TF(pc);
    } 
    return true;
  }
  
  public void TF(L1PcInstance pc) {
    String[] info = new String[11];
    if (pc.get_other2().get_TfCount() > 0) {
      info[0] = String.valueOf(pc.get_other2().get_TfCount());
    } else {
      info[0] = "0";
    } 
    if (pc.get_other2().get_Str() > 0) {
      info[1] = String.valueOf(pc.get_other2().get_Str());
    } else {
      info[1] = "0";
    } 
    if (pc.get_other2().get_Dex() > 0) {
      info[2] = String.valueOf(pc.get_other2().get_Dex());
    } else {
      info[2] = "0";
    } 
    if (pc.get_other2().get_Int() > 0) {
      info[3] = String.valueOf(pc.get_other2().get_Int());
    } else {
      info[3] = "0";
    } 
    if (pc.get_other2().get_Attack() > 0) {
      info[4] = String.valueOf(pc.get_other2().get_Attack());
    } else {
      info[4] = "0";
    } 
    if (pc.get_other2().get_BowAttack() > 0) {
      info[5] = String.valueOf(pc.get_other2().get_BowAttack());
    } else {
      info[5] = "0";
    } 
    if (pc.get_other2().get_Hp() > 0) {
      info[6] = String.valueOf(pc.get_other2().get_Hp());
    } else {
      info[6] = "0";
    } 
    if (pc.get_other2().get_Mp() > 0) {
      info[7] = String.valueOf(pc.get_other2().get_Mp());
    } else {
      info[7] = "0";
    } 
    if (pc.get_other2().get_ReductionDmg() > 0) {
      info[8] = String.valueOf(pc.get_other2().get_ReductionDmg());
    } else {
      info[8] = "0";
    } 
    if (pc.get_other2().get_Sp() > 0) {
      info[9] = String.valueOf(pc.get_other2().get_Sp());
    } else {
      info[9] = "0";
    } 
    if (pc.get_other2().get_Mr() > 0) {
      info[10] = String.valueOf(pc.get_other2().get_Mr());
    } else {
      info[10] = "0";
    } 
    pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(pc.getId(), "tfcount", info));
  }
}
